

package testsubjects;

import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.function.BiConsumer;

public class StaticSerializableBiConsumer implements BiConsumer<String, Integer>, Serializable {

    private String outputFilePath;

    public StaticSerializableBiConsumer(String outputFilePath) {
        this.outputFilePath = outputFilePath;
    }

    @Override
    public void accept(String key, Integer value) {
        try {
            Path filePath = Paths.get(this.outputFilePath);
            String keyValue = key + "#" + value + "\n";
            Files.write(filePath, keyValue.getBytes(), StandardOpenOption.APPEND);
        } catch (IOException e) {
            //Test using this consumer should fail if desired
        }
    }

}
